﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Controls;
using WinAutomator.Library;

namespace WinAutomator.Plugin.BuildIns
{
    public class ControlTestPlugin : IPlugin
    {
        UserControl _control;
        WASetString _process;
        ControlTestViewModel _viewModel;


        public UserControl GetUserControl()
        {
            if (_control == null)
            {
                _control = new ControlTest();
                _control.DataContext = GetViewModel();
            }

            return _control;
        }

        public ControlTestViewModel GetViewModel()
        {
            if (_viewModel == null)
                _viewModel = new ControlTestViewModel();

            return _viewModel;
        }

        public IProcess GetProcess()
        {
            //TODO 0 :If get process for command line _control is null
            if (_control != null)
            {
                ControlTestModelLocator viewModelLocator = (ControlTestModelLocator)_control.Resources["Locator"];

                return viewModelLocator.ControlTest.Model;
            }
            else
            {
                if (_process == null)
                    _process = new WASetString();

                return _process;
            }
        }

        public string Name
        {
            get { return "fds"; }
        }

        public string ToolBoxImageSource
        {
            get { return "/WinAutomator.Plugin.BuildIns;component/Images/2.png"; }
        }



        #region IPlugin Membres


        public Control UserControl
        {
            get { return GetUserControl(); }
        }

        public IProcess Process
        {
            get { return GetProcess(); }
        }

        #endregion

        #region IPlugin Membres


        public PluginViewModel ViewModel
        {
            get { return GetViewModel(); }
        }

        #endregion
    }
}
